<?php
/**
 *
 * @author bichnkn
 * @version 
 */
require_once 'Zend/Loader/PluginLoader.php';
require_once 'Zend/Controller/Action/Helper/Abstract.php';

/**
 * Alert Action Helper
 *
 * @uses actionHelper Zend_Controller_Action_Helper
 */
class Zend_Controller_Action_Helper_Alert extends Zend_Controller_Action_Helper_Abstract {
	/**
	 *
	 * @var Zend_Loader_PluginLoader
	 */
	public $pluginLoader;
	
	/**
	 * Constructor: initialize plugin loader
	 *
	 * @return void
	 */
	public function __construct() {
		// TODO Auto-generated Constructor
		$this->pluginLoader = new Zend_Loader_PluginLoader ();
	}
	
	/**
	 * Strategy pattern: call helper as broker method
	 */
	
	public function direct($msg = null) {
		// TODO Auto-generated 'direct' method
		Zend_Session::start();
		$message = new Zend_Session_Namespace('Message');
		if($msg !== null){
			$message->msg = $msg;
		}
	}
	
	/**
	 * Show message in session
	 * @return string
	 */
	public function show(){
		Zend_Session::start();
		$message = new Zend_Session_Namespace('Message');
		
		if(!empty($message->msg)){
			$str = '<script>';
			$str .= 'alert("'.$message->msg.'");';
			$str .= '</script>';
			$message->unsetAll();
			return $str;
		}
	}
}
